package util.qualitycontainers.qualities.generics;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import util.qualitycontainers.qualities.BuildComponent;


public class BufferedImageQ extends BasicQuality
{

    private BufferedImage myImage;


    public BufferedImageQ (String o) throws IOException
    {
        this(new File(o));
    }


    public BufferedImageQ (File file) throws IOException
    {
        super(file);
        myImage = ImageIO.read(file);
    }


    /**
     * compares the size of these images
     */
    @Override
    public int compareTo (BuildComponent o)
    {
        return this.fileName().compareTo(((BufferedImageQ) o).fileName());

    }


    private String fileName ()
    {
        return ((File) myState).getName();
    }


    public BufferedImage image ()
    {
        return myImage;
    }
}
